#!/bin/sh
preinstall=(zsh delta neovim procs starship nodejs)
for i in ${preinstall[@]}
do 
    echo "installing $i"
    case $i in
        zsh)
            if [ ! `which zsh` ];then
                sudo apt install zsh -y
            fi
            ;;
        delta)
            if [ ! `which delta` ];then
                wget -q --show-progress https://gitee.com/yefengwu/delta/attach_files/876659/download/git-delta-musl_0.9.2_amd64.deb
                sudo dpkg -i git-delta-musl_0.9.2_amd64.deb
                rm git-delta-musl_0.9.2_amd64.deb 
            fi
            ;;
        neovim)
            if [ ! `which neovim` ];then
                cd /usr/local/bin
                sudo wget -q --show-pregress https://github.com/neovim/neovim/releases/latest/download/nvim.appimage 
                sudo chmod +x ./nvim.appimage
                sudo ./nvim.appimage --appimage-extract
                sudo ln -s /usr/local/bin/squashfs-root/usr/bin/nvim /usr/local/bin/nvim
                cd
            fi
            ;;
        procs)
            if [ ! `which procs`];then
                wget -q --show-progress https://gitee.com/yefengwu/procs/attach_files/876685/download/procs-v0.11.10-x86_64-lnx.zip
                unzip procs-v0.11.10-x86_64-lnx.zip
                sudo mv procs /usr/local/bin
                rm procs-v0.11.10-x86_64-lnx.zip
            fi
            ;;
        starship)
            if [ ! `which starship` ];then
                wget -q --show-progress https://gitee.com/yefengwu/starship/attach_files/876692/download/starship-x86_64-unknown-linux-musl.tar.gz
                tar xf starship-x86_64-unknown-linux-musl.tar.gz
                sudo mv starship /usr/local/bin/
                rm starship-x86_64-unknown-linux-musl.tar.gz
            fi
            ;;
        nodejs)
            if [ ! `which node` ];then
                cd /usr/local/share/
                sudo wget https://nodejs.org/dist/v12.18.2/node-v12.18.2-linux-x64.tar.xz
                sudo tar xf node-v12.18.2-linux-x64.tar.xz 
                sudo rm node-v12.18.2-linux-x64.tar.gz
                sudo ln -s /usr/local/share/node-v12.18.2-linux-x64/bin/* /usr/local/bin/
                cd 
            fi
            ;;
        zinit)
            if [ ! `which zinit` ];then
                mkdir -p "$HOME/.zinit" && chmod g-rwX "$HOME/.zinit"
                git clone https://gitee.com/yefengwu/zinit "$HOME/.zinit/bin"
            fi
            ;;
        *)
            echo "$i had installed!"
    esac
done
